import { post } from '@/request/http'
import store from '@/store'

//新增订单
export const addOrEditOrderInfo=({
  attCltId,//客户ID
  attCltName,//attCltName
  attCEtpId,//客户企业ID
  attRemark,//备注
  odcSProvince,//发货地省
  orDeliverypointcity,//发货地市
  odcSArea,//发货地详细地址
  odcDProvince,//收货方省
  orReveivingpartytelcity,//收货方市
  adcDAddress,//收货方详细地址
  attWrkdate,//客户要求作业时间
  attFinwrkdate,//客户要求完成时间
  adcVehicleRequirements,//车型

  // adcCltId,//客户ID
  adcConsigner,//委托人
  adcLinkperson,//联系人
  adcLinkphone,//联系电话
  adcTel,//手机
  adcQq,//QQ,
  adcWechat,//微信
  adcEmail,//EMAIL
  orReveivingparty, //收货方
  orReveivingpartycontacts,//收货方联系人
  orReveivingpartytel,//收货方联系方式
  orShipper,//发货方
  orShippercontacts,//发货方联系人
  orShippertel,//发货方联系方式

  adcSAddress,//发货地地址
  odcDArea,//收货地区县
  trkLong,//车长要求
  adcSX,//X坐标
  adcSY,//Y坐标
  adcSSwrkdate, //装车时间段（开始）
  adcSEwrkdate, //装车时间段（结束）
  adcDX, //X坐标
  adcDY, //Y坐标
  adcDSfinwrkdate, //卸车时间段（开始）
  adcDEfinwrkdate,  //卸车时间段（结束）
  adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
  adcJsfh, //结算方式
  adcJsfhValue, //结算类型
  adcDistanced, //里程
  adcDistancedtime, //运输时间

  //货物
  gdsName,
  gdsType,
  gdsQuantity,
  gdsWeight,
  gdsVolumn,
  gdsRemark,
  gdsPrice
})=>{
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo',{
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          Attorney: {
            fltUuid: store.state.user.FLT_UUID_DX_H,
            attCltId: attCltId.toString(),
            attCltName,
            attCEtpId,
            attRemark,
            attCreator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcSArea,
            odcDProvince,
            orReveivingpartytelcity,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,

          },
          AttDoc: {
            adcVehicleRequirements,
            adcEtpId: store.state.user.FLT_UUID_DX_H,
            adcCltId:attCltId.toString(),
            adcConsigner,
            adcLinkperson,
            adcLinkphone,
            adcTel,
            adcQq,
            adcWechat,
            adcEmail,
            orReveivingparty,
            orReveivingpartycontacts,
            orReveivingpartytel,
            orShipper,
            orShippercontacts,
            orShippertel,
            creator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcSArea,
            adcSAddress,
            odcDProvince,
            orReveivingpartytelcity,
            odcDArea,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
            trkLong,
            adcSX,
            adcSY,
            adcSSwrkdate,
            adcSEwrkdate,
            adcDX,
            adcDY,
            adcDSfinwrkdate,
            adcDEfinwrkdate,
            adcXcfzff,
            adcJsfh,
            adcJsfhValue,
            adcDistanced,
            adcDistancedtime
          },
          Goods: {
            gdsName,
            gdsType,
            gdsQuantity,
            gdsWeight,
            gdsVolumn,
            gdsLength:'1',
            gdsRemark,
            gdsPrice,
            creator: store.state.user.USR_CODE_DX_H
          }
        }
      }
    }
  })
}

//修改
export const EditOrderInfo=({
  uuid,
  attCltId,//客户ID
  attCltName,//attCltName
  attCEtpId,//客户企业ID
  attRemark,//备注
  odcSProvince,//发货地省
  orDeliverypointcity,//发货地市
  odcSArea, // 发货地区县
  adcSAddress,//发货地详细地址
  odcDProvince,//收货方省
  orReveivingpartytelcity,//收货方市
  odcDArea,//收货地区县
  adcDAddress,//收货方详细地址
  attWrkdate,//客户要求作业时间
  attFinwrkdate,//客户要求完成时间
  adcVehicleRequirements,//车型要求

  // adcCltId,//客户ID
  adcConsigner,//委托人
  adcLinkperson,//联系人
  adcLinkphone,//联系电话
  adcTel,//手机
  adcQq,//QQ,
  adcWechat,//微信
  adcEmail,//EMAIL
  orReveivingparty, //收货方
  orReveivingpartycontacts,//收货方联系人
  orReveivingpartytel,//收货方联系方式
  orShipper,//发货方
  orShippercontacts,//发货方联系人
  orShippertel,//发货方联系方式


  trkLong,//车长要求
  adcSX,//X坐标
  adcSY,//Y坐标
  adcSSwrkdate, //装车时间段（开始）
  adcSEwrkdate, //装车时间段（结束）
  adcDX, //X坐标
  adcDY, //Y坐标
  adcDSfinwrkdate, //卸车时间段（开始）
  adcDEfinwrkdate,  //卸车时间段（结束）
  adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
  adcJsfh, //结算方式
  adcJsfhValue, //结算类型
  adcDistanced, //里程
  adcDistancedtime, //运输时间

  //货物
  gdsName,
  gdsType,
  gdsQuantity,
  gdsWeight,
  gdsVolumn,
  gdsRemark,
  gdsPrice
})=>{
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo',{
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          Attorney: {
            uuid,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            attCltId: attCltId.toString(),
            attCltName,
            attCEtpId,
            attRemark,
            adcSAddress,
            attCreator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcDProvince,
            orReveivingpartytelcity,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
          },
          AttDoc: {
            adcVehicleRequirements,
            adcEtpId: store.state.user.FLT_UUID_DX_H,
            adcCltId:attCltId.toString(),
            adcConsigner,
            adcLinkperson,
            adcLinkphone,
            adcTel,
            adcQq,
            adcWechat,
            adcEmail,
            orReveivingparty,
            orReveivingpartycontacts,
            orReveivingpartytel,
            orShipper,
            orShippercontacts,
            orShippertel,
            creator:store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            adcSAddress,
            odcDProvince,
            orReveivingpartytelcity,
            odcDArea,
            odcSArea,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
            trkLong,
            adcSX,
            adcSY,
            adcSSwrkdate,
            adcSEwrkdate,
            adcDX,
            adcDY,
            adcDSfinwrkdate,
            adcDEfinwrkdate,
            adcXcfzff,
            adcJsfh,
            adcJsfhValue,
            adcDistanced,
            adcDistancedtime
          },
          Goods: {
            gdsName,
            gdsType,
            gdsQuantity,
            gdsWeight,
            gdsVolumn,
            gdsLength:'1',
            gdsRemark,
            gdsPrice,
            attLstmodifier: store.state.user.USR_CODE_DX_H
          }
        }
      }
    }
  })
}

//订单取消
export const cancleOrderInfo=({
  uuid,attCode
})=>{
  return post('/FTKJWLHYPT/transoprt/cancleOrderInfo',{
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attCode,
          attLstmodifier:store.state.user.USR_CODE_DX_H,
          attStatus:'DDQX'
        }
      }
    }
  })
}
//查询
export  const orderInfo=({
  attCode,
  attStatus,
  attCreatetimeStart,
  attCreatetimeEnd,
  PageIndex,
  PageSize
})=>{
  return post('/FTKJWLHYPT/transoprt/orderInfo',{
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid:  store.state.user.FLT_UUID_DX_H,
          attCode,
          attStatus,
          attCreatetimeStart,
          attCreatetimeEnd
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT:PageIndex
      },
      PageSize: {
        FTKJWLHYPT:PageSize
      }
    }
  })
}


//订单状态查询
export const orderOperaInfo=({
  attUuid
})=>{
  return post('/FTKJWLHYPT/transoprt/orderOperaInfo',{
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          attUuid,
          optEtpId:store.state.user.DPTID_DX_H,
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT:''
      },
      PageSize: {
        FTKJWLHYPT:''
      }
    }
  })
}

//运单信息查询
export const wayBillInfo=({
  attUuid
})=>{
  return post('/FTKJWLHYPT/transoprt/wayBillInfo',{
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          attUuid,
          //optEtpId:store.state.user.DPTID_DX_H,
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT:''
      },
      PageSize: {
        FTKJWLHYPT:''
      }
    }
  })
}


//订单审核  订单拒绝  取消审核
export const auditOrder=({
  uuid,
  attCode,
  attStatus,
  attAuditdiffering
})=>{
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo',{
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attStatus,  //YSH,SHJJ,QXSH
          attAuditor:store.state.user.USR_CODE_DX_H,
          attCode,
          attAuditdiffering
        }
      }
    }
  })
}
